/** *******************************************************************
 * FlexDatabaseManager
 * @author  Jonnie Spratley
 * @contact jonniespratley@gmail.com
 * @internal
 ******************************************************************* */
package com.jonniespratley.flexdatabasemanager.commands.accounts
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.jonniespratley.flexdatabasemanager.events.accounts.LogoutEvent;
	import com.jonniespratley.flexdatabasemanager.model.ModelLocator;
	import com.jonniespratley.flexdatabasemanager.vo.*;
	
	import mx.collections.ArrayCollection;

	public class LogoutCommand implements ICommand
	{
		private var model:ModelLocator = ModelLocator.getInstance();

		public function execute( event:CairngormEvent ) : void
		{
			
			var evt:LogoutEvent = event as LogoutEvent;
			
			//hide the toolbar and stuff
			model.isLoggedIn = false;
			
			//change the view
			model.workflowState = ModelLocator.MYSQL_LOGIN;
			
			//clear the user
			model.currentUser = null;
			
			//clear all the collections in the model
			model.databaseBackupCollection = new ArrayCollection();
			model.databaseCollection = new ArrayCollection();
			model.databaseFunctionCollection = new ArrayCollection();
			model.databaseIndexCollection = new ArrayCollection();
			model.databaseProcedureCollection = new ArrayCollection();
			model.databasesAndTablesCollection = new ArrayCollection();
			model.databaseViewCollection = new ArrayCollection();;
			
			model.tableAndFieldsCollection = new ArrayCollection();
			model.tableColumnsCollection = new ArrayCollection();
			model.tableDataCollection = new ArrayCollection();
			model.tableIndexCollection = new ArrayCollection();
			model.tableReferenceCollection = new ArrayCollection();
			model.tableStatusCollection = new ArrayCollection();
		}
	}
}